package model01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ReadByteFromFile {
	public static void main(String[] args) {
		int i;
		FileInputStream fis;
		try {
			//doc file co ten la "filebyte.txt" neu khong co se bao loi FileNotFoundException
			fis = new FileInputStream("filebyte.txt");
			
			
				try {
					System.out.println("Du lieu doc duoc tu file filebyte.txt la: ");
					//doc file cho den khi nao tra ve -1(het noi dung file) thi ngung
					do {
						i = fis.read();
						if(i != -1) {
							System.out.print((char)i + "  ");
						}
					} while(i != -1);
					
					//dong stream
					fis.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

}
